import sys
sys.path.append('../')
from RestAPI.amazon.S3 import  VersionControl,Bucket
from RestAPI.core.APIExceptions import *
import unittest
from setting import *

class testVersionControl(unittest.TestCase):
    def test1(self):
        config=VersionControl("""<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> 
  <Status>VersioningState</Status> 
  <MfaDelete>MfaDeleteState</MfaDelete>
</VersioningConfiguration>
        """)
        config2=VersionControl()
        config.enabled(True)
        config.setMfaCode(13222332,534555)
        print 1,config.headers()
        print 1,config.content()
        print 2,config2.headers()
        print 2,config2.content()
    def test2(self):
        #actually adjust VerionControl of a bucket.
        bucket=Bucket('feignwolf-test')
        bucket.setCredential(AUTHID,AUTHKEY)
        versionControlConfiguration=bucket.getVersionControl()
        print versionControlConfiguration.content()
        print "Version Control enabled? %s" % (versionControlConfiguration.enabled())
        versionControlConfiguration.enabled(True)
        print "New configuration:"
        print versionControlConfiguration.content()
        bucket.updateVersionControl(versionControlConfiguration)
        print bucket.getVersionControl().content()
if __name__ == '__main__':
    unittest.main()
